/*
 * Copyright 2010-2011 ESunny.com All right reserved. This software is the confidential and proprietary information of
 * ESunny.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only
 * in accordance with the terms of the license agreement you entered into with ESunny.com.
 */
package com.xjt.common;

import org.apache.struts2.ServletActionContext;

/**
 * cookie工具类
 * 
 * @author Jet Xu 2012-7-31 上午10:13:57
 */
public class ShowCookieUtils {

    public static void addCookie(String name, String value, int expiry) {
        CookieUtils.setCookie(ServletActionContext.getResponse(), name, value, expiry,
                              PropertyUtils.getUrl("query.cookie.domain").getDomain(),
                              PropertyUtils.getUrl("default").getDomain());
    }

    public static void removeCookie(String name) {
        CookieUtils.removeCookie(ServletActionContext.getResponse(), name,
                                 PropertyUtils.getUrl("query.cookie.domain").getDomain(),
                                 PropertyUtils.getUrl("default").getDomain());
    }

    public static String getCookieValue(String name) {
        return CookieUtils.getCookieValue(ServletActionContext.getRequest(), name);
    }

    public static String getCookiePwdName(String userId) {
        return userId + "_pwd";
    }
}
